package me.zk.practice1.hw;

import java.util.Arrays;
import java.util.Scanner;

public class HWBJJ11 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int[] nums = Arrays.stream(scanner.nextLine().split(",")).mapToInt(Integer::parseInt).toArray();

        Arrays.sort(nums);
        boolean[] visit = new boolean[nums.length];
        int count = 0;
        while (true) {
            int sum = 0;
            for (int i = nums.length-1; i >=0 ; i--) {
                if (visit[i]) {
                    continue;
                }

                if (sum+nums[i]<=500) {
                    visit[i] = true;
                    sum+=nums[i];
                }

            }
            count++;
            boolean isok = true;
            for (boolean b : visit) {
                if (!b) {
                    isok = false;
                }
            }
            if (isok) {
                break;
            }
        }
        System.out.println(count);
    }
}
